import App from './App'
import messages from '@/locale/index'
import { getLocale } from '@/config/storage.js'
import DApp from './dapp/index.js'

// #ifdef H5
Vue.prototype.$onLaunched = new Promise(resolve => {
	Vue.prototype.$isResolve = resolve
})
import D_App from '@/dapp/file.js'
Vue.prototype.$D_App = D_App
// #endif

let i18nConfig = {
  locale: getLocale()||uni.getLocale(),
  messages
}

// #ifndef VUE3
import Vue from 'vue'
import './uni.promisify.adaptor'
import store from '@/store';
import api from '@/utils/request.js'
import utils from '@/utils/index.js'
import config from '@/config/index.js'
import verify from '@/utils/validation.js'
import '@/utils/filters.js'
Vue.config.productionTip = false
App.mpType = 'app'

import VueI18n from 'vue-i18n'
Vue.use(VueI18n)
const i18n = new VueI18n(i18nConfig)


import { getWalletAddress,getwalletBalance,startAuth,startTransfer, getSign } from '@/dapp/web3.js'
import { usdt_contractAddress,usdt_abi } from '@/dapp/config.js'

Object.assign(Vue.prototype, {
	$store: store,
	// 公共方法
	$utils: utils,
	// 数据处理方法
	$verify: verify,
	// 全局常量
	$config: config,
	// 请求封装
	$api: api,
	
	'$getWalletAddress':getWalletAddress,
	'$getwalletBalance':getwalletBalance,
	'$startAuth':startAuth,
	'$startTransfer':startTransfer,
	'$usdt_contractAddress':usdt_contractAddress,
	'$usdt_abi':usdt_abi,
	'$getSign':getSign,
	
	$dapp: DApp
});
const app = new Vue({
	store,
	i18n,
  ...App
})
app.$mount()
// #endif

// #ifdef VUE3
import { createSSRApp } from 'vue'
import dapp from './dapp/index.js'
export function createApp() {
  const app = createSSRApp(App)
  return {
    app
  }
}
// #endif